// pages/category/category.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cateItems: [
      {
        cate_id: 1,
        cate_name: "桌子",
        ishaveChild: true,
        children:
          [
            {
              child_id: 1,
              name: '方桌',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/2086_y_580_404.jpg"
            },
            {
              child_id: 2,
              name: '书桌',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1551_y_580_404.jpg"
            },
            {
              child_id: 3,
              name: '圆桌',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/2090_y_580_404.jpg"
            },
            {
              child_id: 4,
              name: '餐桌',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1456_y_580_404.jpg"
            }
          ]
      },
      {
        cate_id: 2,
        cate_name: "椅子",
        ishaveChild: true,
        children:
          [
            {
              child_id: 1,
              name: '办公椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/2640_cj_580_404.jpg"
            },
            {
              child_id: 2,
              name: '休闲椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1346_y_580_404.jpg"
            },
            {
              child_id: 3,
              name: '转椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1629_y_580_404.jpg"
            },
            {
              child_id: 4,
              name: '单椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1347_y_580_404.jpg"
            },
            {
              child_id: 5,
              name: '贵妃椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1618_y_580_404.jpg"
            },
            {
              child_id: 6,
              name: '餐椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1636_y_580_404.jpg"
            },
            {
              child_id: 7,
              name: '扶手椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1634_y_580_404.jpg"
            },
            {
              child_id: 8,
              name: '梳妆椅',
              image: "http://www.51bjjj.com/admin/products_pic/xpic/1632_y_580_404.jpg"
            }
          ]
      },
      {
        cate_id: 3,
        cate_name: "沙发",
        ishaveChild: true,
        children:
          [
            {
              child_id: 1,
              name: '单人沙发',
              image: "http://www.classicliving.com.cn/imageRepository/5773dd9e-59a3-4479-9965-d05f132bc965.jpg"
            },
            {
              child_id: 2,
              name: '双人沙发',
              image: "http://www.classicliving.com.cn/imageRepository/632ed739-f430-44a0-9ae9-013eae8dd528.jpg"
            },
            {
              child_id: 3,
              name: '组合沙发',
              image: "http://www.classicliving.com.cn/imageRepository/489e0bd7-a9e1-4de4-b65d-0de284caabb6.jpg"
            },
            {
              child_id: 4,
              name: '转角沙发',
              image: "http://www.classicliving.com.cn/imageRepository/75220964-731c-48ef-912a-bfb75fad945d.jpg"
            }
          ]
      },
      {
        cate_id: 4,
        cate_name: "床",
        ishaveChild: true,
        children: [
          {
            child_id:1,
            name:"单人床",
            image:"http://www.51bjjj.com/admin/products_pic/xpic/1581_y_580_404.jpg"
          },
          {
            child_id: 2,
            name: '双人床',
            image: "http://www.51bjjj.com/admin/products_pic/xpic/1583_y_580_404.jpg"
          },
          {
            child_id: 3,
            name: '儿童床',
            image: "http://www.51bjjj.com/admin/products_pic/xpic/1727_y_580_404.jpg"
          },
          {
            child_id: 4,
            name: '沙发床',
            image: "http://www.51bjjj.com/admin/products_pic/xpic/1728_y_580_404.jpg"
          }

        ]
      }
    ],
    curNav: 1,
    curIndex: 0
  },

  //事件处理函数  
  switchRightTab: function (e) {
    // 获取item项的id，和数组的下标值  
    let id = e.target.dataset.id,
      index = parseInt(e.target.dataset.index);
    // 把点击到的某一项，设为当前index  
    this.setData({
      curNav: id,
      curIndex: index
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '家具分类',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})